package com.example.Annocation.conditional;

import com.example.Annocation.commons.Person;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

import java.util.Map;

/**
 * @Description TODO
 * @Date 2024/5/14 20:46
 * @Created by houjunfeng
 */
public class ConditionalTest {
    ApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext(ConditionalConfigeration.class);
    @Test
    public void test01(){
        Map<String,Person> personMap = annotationConfigApplicationContext.getBeansOfType(Person.class);
        System.out.println(personMap);
        ConfigurableEnvironment environment = (ConfigurableEnvironment) annotationConfigApplicationContext.getEnvironment();
        String property = environment.getProperty("os.name");
        System.out.println(property);
        //按类型获取的名字会报错，因为注入了两个
//        Person person = annotationConfigApplicationContext.getBean(Person.class);
//        System.out.println(person);

    }
}
